# -*- coding: utf-8 -*-
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
from Page.customerPage import customerPage
import time
class customer():
    def __init__(self,driver):
        self.driver=driver
        self.customerPage=customerPage(self.driver)
    def GrpInsurance(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("head")
        time.sleep(1)
        self.customerPage.groupBtn().click()
    def CustomerManager(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraMenu")
        time.sleep(2)
        self.customerPage.btnCustomerManage().click()
    def CustomerMaintanence(self):
        self.customerPage.btnCustomerMaintenance().click()
        time.sleep(1)
    # 准客户基本信息
    def CustomerIfm(self,CustomerName,IDType,IDNo,GrpNature,BusiCategory,SumNumPeople,SaleChannel,
                    ProvinceName,CityName,CountyName,DetailAddress):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 点击新增
        self.customerPage.btnAddButton().click()
        time.sleep(1)
        # 输入准客户名称
        self.customerPage.inpPreCustomerName().send_keys(CustomerName)
        time.sleep(1)
        # 双击选择证件类型
        ActionChains(self.driver).double_click(self.customerPage.secIDType()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(IDType)
        time.sleep(1)
        # 输入证件号码
        self.customerPage.inpIDNo().send_keys(IDNo)
        time.sleep(1)
        # 双击选择单位性质
        ActionChains(self.driver).double_click(self.customerPage.secGrpNature()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(GrpNature)
        time.sleep(1)
        # 双击选择行业分类
        ActionChains(self.driver).double_click(self.customerPage.secBusiCategory()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(BusiCategory)
        time.sleep(1)
        # 输入单位总人数
        self.customerPage.inpSumNumPeople().send_keys(SumNumPeople)
        time.sleep(1)
        # 双击选择销售渠道
        ActionChains(self.driver).double_click(self.customerPage.secSaleChannel()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(SaleChannel)
        time.sleep(1)
        # 双击选择省份
        ActionChains(self.driver).double_click(self.customerPage.secProvinceName()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(ProvinceName)
        time.sleep(1)
        # 双击选择市
        ActionChains(self.driver).double_click(self.customerPage.secCityName()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(CityName)
        time.sleep(1)
        # 双击选择区/县
        ActionChains(self.driver).double_click(self.customerPage.secCountyName()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(CountyName)
        time.sleep(1)
        # 详细地址
        self.customerPage.inpDetailAddress().send_keys(DetailAddress)
        time.sleep(1)
    def LinkManIfm(self,LinkMan,Mobile,Phone,Depart,Post,Email):
        self.customerPage.inpLinkMan().send_keys(LinkMan)
        time.sleep(1)
        self.customerPage.inpMobile().send_keys(Mobile)
        time.sleep(1)
        self.customerPage.inpPhone().send_keys(Phone)
        time.sleep(1)
        self.customerPage.inpDepart().send_keys(Depart)
        time.sleep(1)
        self.customerPage.inpPost().send_keys(Post)
        time.sleep(1)
        self.customerPage.inpEmail().send_keys(Email)
        time.sleep(1)
        self.customerPage.btnAddButton().click()
        time.sleep(1)
        window1 = self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.customerPage.butSubmit().click()
    def InquiryApply(self,ProdType,PremMode,ValDateType,RenewFlag):
        window2 = self.driver.window_handles
        self.driver.switch_to.window(window2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        self.customerPage.btnAppButton().click()
        time.sleep(1)
        # 产品类型
        ActionChains(self.driver).double_click(self.customerPage.secProdType()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(ProdType)
        time.sleep(1)
        # 保费分摊方式
        ActionChains(self.driver).double_click(self.customerPage.secPremMode()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(PremMode)
        time.sleep(1)
        # 契约生效日类型
        ActionChains(self.driver).double_click(self.customerPage.secValDateType()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(ValDateType)
        time.sleep(1)
        # 是否为续保业务
        ActionChains(self.driver).double_click(self.customerPage.secRenewFlag()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(RenewFlag)
        time.sleep(1)
        # 统一标准
        self.customerPage.Unifiedstandard().click()
        time.sleep(1)
        # 基本信息保存
        self.customerPage.btnSaveIfm().click()
        time.sleep(1)
        window3 = self.driver.window_handles
        self.driver.switch_to.window(window3[-1])
        self.customerPage.butSubmit().click()
    def PlanInformation(self):
        window2 = self.driver.window_handles
        self.driver.switch_to.window(window2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        self.customerPage.btnNextStep().click()
        time.sleep(1)
    # 佣金信息
    def CommissionInformation(self,btnAgentDetailGrid1,PreCustomerNo,CommissionRate):
        self.customerPage.btnClose().click()
        time.sleep(1)
        window1= self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        self.customerPage.btnCommissionInformation().click()
        time.sleep(1)
        window2 = self.driver.window_handles
        self.driver.switch_to.window(window2[-1])
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 点击“+”
        self.customerPage.btnAgentDetailGridaddOne().click()
        time.sleep(1)
        # 客户所属渠道
        ActionChains(self.driver).double_click(self.customerPage.btnAgentDetailGrid1()).perform()
        time.sleep(1)
        Select(self.customerPage.codeselect()).select_by_visible_text(btnAgentDetailGrid1)
        time.sleep(1)
        # 客户经理代码
        ActionChains(self.driver).double_click(self.customerPage.btnAgentID()).perform()
        time.sleep(1)
        window3 = self.driver.window_handles
        self.driver.switch_to.window(window3[-1])
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 输入客户经理名称
        self.customerPage.inpPreCustomerNo().send_keys(PreCustomerNo)
        time.sleep(1)
        # 点击查询
        self.customerPage.btnQuery().click()
        time.sleep(1)
        # 选择数据
        self.customerPage.radChoose().click()
        time.sleep(1)
        # 点击选择按钮
        self.customerPage.btnChoose().click()
        time.sleep(1)
        window4 = self.driver.window_handles
        self.driver.switch_to.window(window4[-1])
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 分佣比例
        self.customerPage.inpAgentDetailGrid5().send_keys(CommissionRate)
        time.sleep(1)
        # 点击保存
        self.customerPage.btnSave().click()
        time.sleep(1)
        window5 = self.driver.window_handles
        self.driver.switch_to.window(window5[-1])
        self.customerPage.butSubmit().click()
        time.sleep(1)
        window6 = self.driver.window_handles
        self.driver.switch_to.window(window6[-1])
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        self.customerPage.btnClose1().click()
        time.sleep(1)
        window7 = self.driver.window_handles
        self.driver.switch_to.window(window7[-1])
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 点击下一步
        self.customerPage.btnNextStep1().click()
        time.sleep(1)
        # 询价信息确认
        self.customerPage.btnInquirySumbit().click()
        time.sleep(1)
        window8 = self.driver.window_handles
        self.driver.switch_to.window(window8[-1])
        self.customerPage.butSubmit().click()
        time.sleep(1)
        window9 = self.driver.window_handles
        self.driver.switch_to.window(window9[-1])
        time.sleep(1)






























